package com.study.pojo;

import lombok.Data;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.*;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * @author Qi XueSong
 */
@Data
public class Result implements BeanNameAware, BeanFactoryAware, ApplicationContextAware, InitializingBean, DisposableBean {

    /**
     * 返回的状态
     */
    private String status;

    /**
     * 返回到前台的信息
     */
    private String message;

    @Override
    public void setBeanName(String s) {
        System.out.println("注册bean时定义的id："+ s);
    }


    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("管理当前bean的beanFactory为："+ beanFactory);
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("高级容器接口applicationContext：" + applicationContext);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        System.out.println("afterPropertiesSet......");
    }


    public void initMethod() {
        System.out.println("init-method....");
    }

    //替代init方法的注解，但是它和initMethod 方法执行顺序是不同的
    @PostConstruct
    public void postCoustrcut() {
        System.out.println("postCoustrcut");
    }


    @PreDestroy
    public void PreDestroy(){
        System.out.println("PreDestroy...");
    }

    @Override
    public void destroy() throws Exception {
        System.out.println("destroy.....");
    }

    public void destroyMethod() {
        System.out.println("destroy-method....");
    }
}
